<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>geosnap.visualize.commviz &#8212; geosnap v0.3.1 Manual</title>
    <link rel="stylesheet" href="../../../_static/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/pysal-styles.css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <link rel="shortcut icon" href="../../../_static/geosnap.ico"/>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../../../_static/js/jquery-1.11.0.min.js "></script>
<script type="text/javascript" src="../../../_static/js/jquery-fix.js "></script>
<script type="text/javascript" src="../../../_static/bootstrap-3.3.7/js/bootstrap.min.js "></script>
<script type="text/javascript" src="../../../_static/bootstrap-sphinx.js "></script>

  </head><body>

  <div id="navbar" class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="../../../index.html"><span><img src="../../../_static/geosnap.svg"></span>
          geosnap</a>
        <span class="navbar-text navbar-version pull-left"><b>0.3.1</b></span>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            
                <li><a href="../../../installation.html">Installation</a></li>
                <li><a href="../../../api.html">API</a></li>
                <li><a href="../../../data.html">Data</a></li>
                <li><a href="https://spatialucr.github.io/geosnap-guide/">User Guide</a></li>
                <li><a href="../../../references.html">References</a></li>
            
            
              <li class="dropdown globaltoc-container">
  <a role="button"
     id="dLabelGlobalToc"
     data-toggle="dropdown"
     data-target="#"
     href="../../../index.html">Site <b class="caret"></b></a>
  <ul class="dropdown-menu globaltoc"
      role="menu"
      aria-labelledby="dLabelGlobalToc"><p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../installation.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../installation.html#installing-a-released-version">Installing a released version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../installation.html#installing-development-version">Installing development version</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../api.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#io-module">IO Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#the-community-class">The Community Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#analyze-module">Analyze Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#harmonize-module">Harmonize Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api.html#visualize-module">Visualize Module</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../references.html">References</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../data.html">Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../data.html#tabular-data">Tabular Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../data.html#geo-data">Geo Data</a></li>
</ul>
</li>
</ul>
</ul>
</li>
              
                <li class="dropdown">
  <a role="button"
     id="dLabelLocalToc"
     data-toggle="dropdown"
     data-target="#"
     href="#">Page <b class="caret"></b></a>
  <ul class="dropdown-menu localtoc"
      role="menu"
      aria-labelledby="dLabelLocalToc"></ul>
</li>
              
            
            
            
            
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="../../../search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="body col-md-12 content" role="main">
      
  <h1>Source code for geosnap.visualize.commviz</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">mapclassify</span> <span class="kn">import</span> <span class="o">*</span>


<div class="viewcode-block" id="explore"><a class="viewcode-back" href="../../../generated/geosnap.visualize.explore.html#geosnap.visualize.explore">[docs]</a><span class="k">def</span> <span class="nf">explore</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="s2">&quot;census&quot;</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Launch an interactive visualization portal.</span>

<span class="sd">    This function launches an interactive dataset explorer based on plotly&#39;s `dash`</span>
<span class="sd">    Currently it is still experimental, but it provides a set of interactive widgets</span>
<span class="sd">    and maps that allow users to rapidly create  metropolitan-scale datasets and choropleth</span>
<span class="sd">    webmaps using a variety of census data.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    data : str</span>
<span class="sd">        Which dataset to explore. Options include &quot;census, &quot;ltdb&quot;, and &quot;ncdb&quot; (the default is &quot;census&quot;).</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    None</span>
<span class="sd">        Launches a web-browser with the interactive visualization.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">mem</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_metro&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
    <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_comm&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>

    <span class="kn">import</span> <span class="nn">dash</span>
    <span class="kn">import</span> <span class="nn">dash_core_components</span> <span class="k">as</span> <span class="nn">dcc</span>
    <span class="kn">import</span> <span class="nn">dash_html_components</span> <span class="k">as</span> <span class="nn">html</span>
    <span class="kn">import</span> <span class="nn">dash_bootstrap_components</span> <span class="k">as</span> <span class="nn">dbc</span>
    <span class="kn">import</span> <span class="nn">webbrowser</span>
    <span class="kn">import</span> <span class="nn">palettable</span>
    <span class="kn">import</span> <span class="nn">json</span>
    <span class="kn">from</span> <span class="nn">geosnap</span> <span class="kn">import</span> <span class="n">Community</span><span class="p">,</span> <span class="n">datasets</span>

    <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span>

    <span class="n">mapbox_access_token</span> <span class="o">=</span> <span class="p">(</span>
        <span class="s2">&quot;pk.eyJ1Ijoia25hYXB0aW1lIiwiYSI6ImlQeUJxazgifQ.35yYbOewGVVf7OkcM64obQ&quot;</span>
    <span class="p">)</span>
    <span class="n">external_stylesheets</span> <span class="o">=</span> <span class="p">[</span><span class="n">dbc</span><span class="o">.</span><span class="n">themes</span><span class="o">.</span><span class="n">JOURNAL</span><span class="p">]</span>

    <span class="n">opts</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">colname</span> <span class="ow">in</span> <span class="n">datasets</span><span class="o">.</span><span class="n">codebook</span><span class="p">()</span><span class="o">.</span><span class="n">variable</span><span class="p">:</span>
        <span class="n">val</span> <span class="o">=</span> <span class="n">colname</span>
        <span class="k">if</span> <span class="n">colname</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;n_&quot;</span><span class="p">):</span>
            <span class="n">colname</span> <span class="o">=</span> <span class="n">colname</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
        <span class="k">elif</span> <span class="n">colname</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;p_&quot;</span><span class="p">):</span>
            <span class="n">colname</span> <span class="o">=</span> <span class="n">colname</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
            <span class="n">colname</span> <span class="o">=</span> <span class="n">colname</span> <span class="o">+</span> <span class="s2">&quot; (%)&quot;</span>
        <span class="n">colname</span> <span class="o">=</span> <span class="n">colname</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">,</span> <span class="s2">&quot; &quot;</span><span class="p">)</span>
        <span class="n">colname</span> <span class="o">=</span> <span class="n">colname</span><span class="o">.</span><span class="n">title</span><span class="p">()</span>
        <span class="n">opts</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="n">colname</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">val</span><span class="p">})</span>

    <span class="c1"># opts = [{&#39;label&#39;: col.title(), &#39;value&#39;: col} for col in dictionary.variable]</span>

    <span class="n">k_opts</span> <span class="o">=</span> <span class="p">[{</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">),</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">k</span><span class="p">}</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">11</span><span class="p">)]</span>
    <span class="n">data_type</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;sequential&quot;</span><span class="p">,</span> <span class="s2">&quot;diverging&quot;</span><span class="p">,</span> <span class="s2">&quot;qualitative&quot;</span><span class="p">]</span>
    <span class="n">data_opts</span> <span class="o">=</span> <span class="p">[{</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="n">scheme</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">scheme</span><span class="o">.</span><span class="n">title</span><span class="p">()}</span> <span class="k">for</span> <span class="n">scheme</span> <span class="ow">in</span> <span class="n">data_type</span><span class="p">]</span>

    <span class="n">scheme_dispatch</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s2">&quot;Equal Interval&quot;</span><span class="p">:</span> <span class="n">EqualInterval</span><span class="p">,</span>
        <span class="s2">&quot;Fisher Jenks&quot;</span><span class="p">:</span> <span class="n">FisherJenks</span><span class="p">,</span>
        <span class="s2">&quot;Head-Tail Breaks&quot;</span><span class="p">:</span> <span class="n">HeadTailBreaks</span><span class="p">,</span>
        <span class="s2">&quot;Jenks Caspall&quot;</span><span class="p">:</span> <span class="n">JenksCaspall</span><span class="p">,</span>
        <span class="s2">&quot;Max-P Classifier&quot;</span><span class="p">:</span> <span class="n">MaxP</span><span class="p">,</span>
        <span class="s2">&quot;Maximum Breaks&quot;</span><span class="p">:</span> <span class="n">MaximumBreaks</span><span class="p">,</span>
        <span class="s2">&quot;Natural Breaks&quot;</span><span class="p">:</span> <span class="n">NaturalBreaks</span><span class="p">,</span>
        <span class="s2">&quot;Quantiles&quot;</span><span class="p">:</span> <span class="n">Quantiles</span><span class="p">,</span>
        <span class="s2">&quot;Percentiles&quot;</span><span class="p">:</span> <span class="n">Percentiles</span><span class="p">,</span>
    <span class="p">}</span>

    <span class="n">sequential</span> <span class="o">=</span> <span class="p">[</span>
        <span class="s2">&quot;Blues&quot;</span><span class="p">,</span>
        <span class="s2">&quot;BuGn&quot;</span><span class="p">,</span>
        <span class="s2">&quot;BuPu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;GnBu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Greens&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Greys&quot;</span><span class="p">,</span>
        <span class="s2">&quot;OrRd&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Oranges&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PuBu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PuBuGn&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PuRd&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Purples&quot;</span><span class="p">,</span>
        <span class="s2">&quot;RdPu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Reds&quot;</span><span class="p">,</span>
        <span class="s2">&quot;YlGn&quot;</span><span class="p">,</span>
        <span class="s2">&quot;YlGnBu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;YlOrBr&quot;</span><span class="p">,</span>
        <span class="s2">&quot;YlOrRd&quot;</span><span class="p">,</span>
    <span class="p">]</span>
    <span class="n">diverging</span> <span class="o">=</span> <span class="p">[</span>
        <span class="s2">&quot;BrBG&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PRGn&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PiYG&quot;</span><span class="p">,</span>
        <span class="s2">&quot;PuOr&quot;</span><span class="p">,</span>
        <span class="s2">&quot;RdBu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;RdGy&quot;</span><span class="p">,</span>
        <span class="s2">&quot;RdYlBu&quot;</span><span class="p">,</span>
        <span class="s2">&quot;RdYlGn&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Spectral&quot;</span><span class="p">,</span>
    <span class="p">]</span>
    <span class="n">qualitative</span> <span class="o">=</span> <span class="p">[</span>
        <span class="s2">&quot;Accent&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Dark2&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Paired&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Pastel1&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Pastel2&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Set1&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Set2&quot;</span><span class="p">,</span>
        <span class="s2">&quot;Set3&quot;</span><span class="p">,</span>
    <span class="p">]</span>

    <span class="n">cmaps</span> <span class="o">=</span> <span class="n">sequential</span> <span class="o">+</span> <span class="n">diverging</span> <span class="o">+</span> <span class="n">qualitative</span>

    <span class="n">cmap_opts</span> <span class="o">=</span> <span class="p">[{</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="n">cmap</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">cmap</span><span class="p">}</span> <span class="k">for</span> <span class="n">cmap</span> <span class="ow">in</span> <span class="n">cmaps</span><span class="p">]</span>

    <span class="n">scheme_opts</span> <span class="o">=</span> <span class="p">[{</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">),</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">v</span><span class="p">}</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">scheme_dispatch</span><span class="p">]</span>

    <span class="n">metro_opts</span> <span class="o">=</span> <span class="p">[</span>
        <span class="p">{</span><span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">metro</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]),</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="n">metro</span><span class="p">[</span><span class="s2">&quot;geoid&quot;</span><span class="p">]}</span>
        <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">metro</span> <span class="ow">in</span> <span class="n">datasets</span><span class="o">.</span><span class="n">msas</span><span class="p">()</span><span class="o">.</span><span class="n">iterrows</span><span class="p">()</span>
    <span class="p">]</span>

    <span class="n">precomputed_color_ranges</span> <span class="o">=</span> <span class="n">palettable</span><span class="o">.</span><span class="n">colorbrewer</span><span class="o">.</span><span class="n">sequential</span><span class="o">.</span><span class="n">Blues_6</span><span class="o">.</span><span class="n">hex_colors</span>

    <span class="n">trace</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="s2">&quot;scattermapbox&quot;</span><span class="p">,</span> <span class="n">autocolorscale</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;metro&quot;</span><span class="p">)</span>

    <span class="n">navbar</span> <span class="o">=</span> <span class="n">dbc</span><span class="o">.</span><span class="n">NavbarSimple</span><span class="p">(</span>
        <span class="n">children</span><span class="o">=</span><span class="p">[</span>
            <span class="n">dbc</span><span class="o">.</span><span class="n">NavItem</span><span class="p">(</span><span class="n">dbc</span><span class="o">.</span><span class="n">NavLink</span><span class="p">(</span><span class="s2">&quot;geosnap&quot;</span><span class="p">,</span> <span class="n">href</span><span class="o">=</span><span class="s2">&quot;http://spatial.ucr.edu&quot;</span><span class="p">)),</span>
            <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenu</span><span class="p">(</span>
                <span class="n">nav</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                <span class="n">in_navbar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                <span class="n">label</span><span class="o">=</span><span class="s2">&quot;Menu&quot;</span><span class="p">,</span>
                <span class="n">children</span><span class="o">=</span><span class="p">[</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span><span class="s2">&quot;Explore Variables&quot;</span><span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span><span class="s2">&quot;Identify Neighborhoods&quot;</span><span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span><span class="s2">&quot;Model Neighborhood Change&quot;</span><span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span><span class="n">divider</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span><span class="s2">&quot;Docs&quot;</span><span class="p">,</span> <span class="n">href</span><span class="o">=</span><span class="s2">&quot;http://geosnap.readthedocs.io&quot;</span><span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">DropdownMenuItem</span><span class="p">(</span>
                        <span class="s2">&quot;Github&quot;</span><span class="p">,</span> <span class="n">href</span><span class="o">=</span><span class="s2">&quot;http://github.com/spatialucr/geosnap&quot;</span>
                    <span class="p">),</span>
                <span class="p">],</span>
            <span class="p">),</span>
        <span class="p">],</span>
        <span class="n">brand</span><span class="o">=</span><span class="s2">&quot;cgs&quot;</span><span class="p">,</span>
        <span class="n">brand_href</span><span class="o">=</span><span class="s2">&quot;#&quot;</span><span class="p">,</span>
        <span class="n">sticky</span><span class="o">=</span><span class="s2">&quot;top&quot;</span><span class="p">,</span>
        <span class="n">dark</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
        <span class="n">color</span><span class="o">=</span><span class="s2">&quot;dark&quot;</span><span class="p">,</span>
    <span class="p">)</span>

    <span class="n">body</span> <span class="o">=</span> <span class="n">dbc</span><span class="o">.</span><span class="n">Container</span><span class="p">(</span>
        <span class="p">[</span>
            <span class="n">html</span><span class="o">.</span><span class="n">H2</span><span class="p">(</span>
                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Variable Explorer&quot;</span><span class="p">,</span>
                <span class="n">style</span><span class="o">=</span><span class="p">{</span>
                    <span class="s2">&quot;textAlign&quot;</span><span class="p">:</span> <span class="s2">&quot;center&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;4%&quot;</span><span class="p">,</span>
                <span class="p">},</span>
            <span class="p">),</span>
            <span class="n">dbc</span><span class="o">.</span><span class="n">Row</span><span class="p">(</span>
                <span class="p">[</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">Col</span><span class="p">(</span>
                        <span class="p">[</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Metropolitan Region&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;4%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Dropdown</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;metro-choice&quot;</span><span class="p">,</span>
                                <span class="n">options</span><span class="o">=</span><span class="n">metro_opts</span><span class="p">,</span>
                                <span class="n">value</span><span class="o">=</span><span class="s2">&quot;41740&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Variable&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span> <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Dropdown</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;overlay-choice&quot;</span><span class="p">,</span>
                                <span class="n">options</span><span class="o">=</span><span class="n">opts</span><span class="p">,</span>
                                <span class="n">value</span><span class="o">=</span><span class="s2">&quot;median_home_value&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Classification Scheme&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span> <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Dropdown</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;scheme-choice&quot;</span><span class="p">,</span>
                                <span class="n">options</span><span class="o">=</span><span class="n">scheme_opts</span><span class="p">,</span>
                                <span class="n">value</span><span class="o">=</span><span class="s2">&quot;Equal Interval&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Colormap&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span> <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Dropdown</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;cmap-choice&quot;</span><span class="p">,</span>
                                <span class="n">options</span><span class="o">=</span><span class="n">cmap_opts</span><span class="p">,</span>
                                <span class="n">value</span><span class="o">=</span><span class="s2">&quot;YlOrBr&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Number of Classes&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span> <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Dropdown</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;k-choice&quot;</span><span class="p">,</span>
                                <span class="n">options</span><span class="o">=</span><span class="n">k_opts</span><span class="p">,</span>
                                <span class="n">value</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">H5</span><span class="p">(</span>
                                <span class="n">children</span><span class="o">=</span><span class="s2">&quot;Year&quot;</span><span class="p">,</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span> <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">},</span>
                            <span class="p">),</span>
                            <span class="n">html</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span>
                                <span class="n">dcc</span><span class="o">.</span><span class="n">Slider</span><span class="p">(</span>
                                    <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;year-slider&quot;</span><span class="p">,</span>
                                    <span class="nb">min</span><span class="o">=</span><span class="mi">1970</span><span class="p">,</span>
                                    <span class="nb">max</span><span class="o">=</span><span class="mi">2010</span><span class="p">,</span>
                                    <span class="n">value</span><span class="o">=</span><span class="mi">2010</span><span class="p">,</span>
                                    <span class="n">marks</span><span class="o">=</span><span class="p">{</span>
                                        <span class="nb">str</span><span class="p">(</span><span class="n">year</span><span class="p">):</span> <span class="nb">str</span><span class="p">(</span><span class="n">year</span><span class="p">)</span>
                                        <span class="k">for</span> <span class="n">year</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1970</span><span class="p">,</span> <span class="mi">2011</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
                                    <span class="p">},</span>
                                    <span class="n">step</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span>
                                <span class="p">),</span>
                                <span class="n">style</span><span class="o">=</span><span class="p">{</span>
                                    <span class="s2">&quot;padding-left&quot;</span><span class="p">:</span> <span class="s2">&quot;5%&quot;</span><span class="p">,</span>
                                    <span class="s2">&quot;padding-right&quot;</span><span class="p">:</span> <span class="s2">&quot;5%&quot;</span><span class="p">,</span>
                                    <span class="s2">&quot;padding-top&quot;</span><span class="p">:</span> <span class="s2">&quot;2%&quot;</span><span class="p">,</span>
                                    <span class="s2">&quot;padding-bottom&quot;</span><span class="p">:</span> <span class="s2">&quot;4%&quot;</span><span class="p">,</span>
                                <span class="p">},</span>
                            <span class="p">),</span>
                        <span class="p">],</span>
                        <span class="n">md</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span>
                    <span class="p">),</span>
                    <span class="n">dbc</span><span class="o">.</span><span class="n">Col</span><span class="p">(</span>
                        <span class="p">[</span>
                            <span class="n">dcc</span><span class="o">.</span><span class="n">Loading</span><span class="p">(</span>
                                <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;loading-output-1&quot;</span><span class="p">,</span>
                                <span class="n">children</span><span class="o">=</span><span class="p">[</span><span class="n">dcc</span><span class="o">.</span><span class="n">Graph</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s2">&quot;map-display&quot;</span><span class="p">)],</span>
                                <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;default&quot;</span><span class="p">,</span>
                            <span class="p">)</span>
                        <span class="p">],</span>
                        <span class="n">md</span><span class="o">=</span><span class="mi">9</span><span class="p">,</span>
                    <span class="p">),</span>
                <span class="p">]</span>
            <span class="p">),</span>
        <span class="p">],</span>
        <span class="n">className</span><span class="o">=</span><span class="s2">&quot;mt-4&quot;</span><span class="p">,</span>
    <span class="p">)</span>

    <span class="n">app</span> <span class="o">=</span> <span class="n">dash</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="n">external_stylesheets</span><span class="o">=</span><span class="n">external_stylesheets</span><span class="p">)</span>

    <span class="n">app</span><span class="o">.</span><span class="n">layout</span> <span class="o">=</span> <span class="n">html</span><span class="o">.</span><span class="n">Div</span><span class="p">([</span><span class="n">navbar</span><span class="p">,</span> <span class="n">body</span><span class="p">])</span>

    <span class="n">map_layout</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Layer name&quot;</span><span class="p">,</span>
                <span class="s2">&quot;sourcetype&quot;</span><span class="p">:</span> <span class="s2">&quot;geojson&quot;</span><span class="p">,</span>
                <span class="s2">&quot;opacity&quot;</span><span class="p">:</span> <span class="mf">0.8</span><span class="p">,</span>
                <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;scattermapbox&quot;</span><span class="p">,</span>
                <span class="s2">&quot;showlegend&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                <span class="s2">&quot;textposition&quot;</span><span class="p">:</span> <span class="s2">&quot;top&quot;</span><span class="p">,</span>
                <span class="s2">&quot;text&quot;</span><span class="p">:</span> <span class="s2">&quot;geoid&quot;</span><span class="p">,</span>
                <span class="s2">&quot;mode&quot;</span><span class="p">:</span> <span class="s2">&quot;markers+text&quot;</span><span class="p">,</span>
                <span class="s2">&quot;hoverinfo&quot;</span><span class="p">:</span> <span class="s2">&quot;text&quot;</span><span class="p">,</span>
                <span class="s2">&quot;marker&quot;</span><span class="p">:</span> <span class="nb">dict</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;white&quot;</span><span class="p">,</span> <span class="n">opacity</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">],</span>
        <span class="s2">&quot;layout&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;autosize&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;hovermode&quot;</span><span class="p">:</span> <span class="s2">&quot;closest&quot;</span><span class="p">,</span>
            <span class="s2">&quot;margin&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;l&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;b&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;t&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
            <span class="s2">&quot;showlegend&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;mapbox&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s2">&quot;accesstoken&quot;</span><span class="p">:</span> <span class="n">mapbox_access_token</span><span class="p">,</span>
                <span class="s2">&quot;center&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;lat&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;lon&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
                <span class="s2">&quot;style&quot;</span><span class="p">:</span> <span class="s2">&quot;light&quot;</span><span class="p">,</span>
                <span class="s2">&quot;zoom&quot;</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span>
                <span class="s2">&quot;bearing&quot;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
                <span class="s2">&quot;pitch&quot;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
            <span class="p">},</span>
        <span class="p">},</span>
    <span class="p">}</span>

    <span class="nd">@app</span><span class="o">.</span><span class="n">callback</span><span class="p">(</span>
        <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Output</span><span class="p">(</span><span class="s2">&quot;map-display&quot;</span><span class="p">,</span> <span class="s2">&quot;figure&quot;</span><span class="p">),</span>
        <span class="p">[</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;overlay-choice&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;metro-choice&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;year-slider&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;k-choice&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;scheme-choice&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
            <span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Input</span><span class="p">(</span><span class="s2">&quot;cmap-choice&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">),</span>
        <span class="p">],</span>
    <span class="p">)</span>
    <span class="k">def</span> <span class="nf">update_map</span><span class="p">(</span>
        <span class="n">overlay_choice</span><span class="p">,</span> <span class="n">metro_choice</span><span class="p">,</span> <span class="n">year_choice</span><span class="p">,</span> <span class="n">k_choice</span><span class="p">,</span> <span class="n">scheme_choice</span><span class="p">,</span> <span class="n">cmap_choice</span>
    <span class="p">):</span>

        <span class="n">readers</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;census&quot;</span><span class="p">:</span> <span class="n">Community</span><span class="o">.</span><span class="n">from_census</span><span class="p">,</span>
            <span class="s2">&quot;ltdb&quot;</span><span class="p">:</span> <span class="n">Community</span><span class="o">.</span><span class="n">from_ltdb</span><span class="p">,</span>
            <span class="s2">&quot;ncdb&quot;</span><span class="p">:</span> <span class="n">Community</span><span class="o">.</span><span class="n">from_ncdb</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="k">if</span> <span class="n">cmap_choice</span> <span class="ow">in</span> <span class="n">qualitative</span><span class="p">:</span>
            <span class="n">cmap_type</span> <span class="o">=</span> <span class="s2">&quot;qualitative&quot;</span>
        <span class="k">elif</span> <span class="n">cmap_choice</span> <span class="ow">in</span> <span class="n">sequential</span><span class="p">:</span>
            <span class="n">cmap_type</span> <span class="o">=</span> <span class="s2">&quot;sequential&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">cmap_type</span> <span class="o">=</span> <span class="s2">&quot;diverging&quot;</span>

        <span class="n">tmp</span> <span class="o">=</span> <span class="n">map_layout</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">metro_choice</span> <span class="o">!=</span> <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_metro&quot;</span><span class="p">]:</span>
            <span class="n">community</span> <span class="o">=</span> <span class="n">readers</span><span class="p">[</span><span class="n">mem</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">]](</span><span class="n">msa_fips</span><span class="o">=</span><span class="n">metro_choice</span><span class="p">)</span>
            <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_metro&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">metro_choice</span>
            <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_comm&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">community</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">community</span> <span class="o">=</span> <span class="n">mem</span><span class="p">[</span><span class="s2">&quot;last_comm&quot;</span><span class="p">]</span>

        <span class="n">gdf</span> <span class="o">=</span> <span class="n">community</span><span class="o">.</span><span class="n">gdf</span><span class="p">[</span><span class="n">community</span><span class="o">.</span><span class="n">gdf</span><span class="o">.</span><span class="n">year</span> <span class="o">==</span> <span class="n">year_choice</span><span class="p">]</span>

        <span class="n">gdf</span> <span class="o">=</span> <span class="n">gdf</span><span class="o">.</span><span class="n">dropna</span><span class="p">(</span><span class="n">subset</span><span class="o">=</span><span class="p">[</span><span class="n">overlay_choice</span><span class="p">])</span><span class="o">.</span><span class="n">reset_index</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">scheme_choice</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;Max-P Classifier&quot;</span><span class="p">,</span> <span class="s2">&quot;Maximum Breaks&quot;</span><span class="p">,</span> <span class="s2">&quot;Head-Tail Breaks&quot;</span><span class="p">]:</span>
            <span class="n">classes</span> <span class="o">=</span> <span class="n">scheme_dispatch</span><span class="p">[</span><span class="n">scheme_choice</span><span class="p">](</span><span class="n">gdf</span><span class="p">[</span><span class="n">overlay_choice</span><span class="p">])</span><span class="o">.</span><span class="n">yb</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">classes</span> <span class="o">=</span> <span class="n">scheme_dispatch</span><span class="p">[</span><span class="n">scheme_choice</span><span class="p">](</span><span class="n">gdf</span><span class="p">[</span><span class="n">overlay_choice</span><span class="p">],</span> <span class="n">k</span><span class="o">=</span><span class="n">k_choice</span><span class="p">)</span><span class="o">.</span><span class="n">yb</span>
        <span class="n">gdf</span> <span class="o">=</span> <span class="n">gdf</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span><span class="n">cl</span><span class="o">=</span><span class="n">classes</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">k_choice</span><span class="p">:</span>
            <span class="n">k_choice</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">gdf</span><span class="o">.</span><span class="n">cl</span><span class="o">.</span><span class="n">unique</span><span class="p">())</span>
        <span class="c1"># Create a layer for each region colored by LEP value</span>

        <span class="n">gdf</span> <span class="o">=</span> <span class="n">gdf</span><span class="p">[[</span><span class="s2">&quot;geoid&quot;</span><span class="p">,</span> <span class="s2">&quot;cl&quot;</span><span class="p">,</span> <span class="s2">&quot;geometry&quot;</span><span class="p">]]</span>

        <span class="n">layers</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">precomputed_color_ranges</span> <span class="o">=</span> <span class="n">palettable</span><span class="o">.</span><span class="n">colorbrewer</span><span class="o">.</span><span class="n">get_map</span><span class="p">(</span>
            <span class="n">cmap_choice</span><span class="p">,</span> <span class="n">cmap_type</span><span class="p">,</span> <span class="n">k_choice</span>
        <span class="p">)</span><span class="o">.</span><span class="n">hex_colors</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">lyr</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">precomputed_color_ranges</span><span class="p">):</span>
            <span class="n">example</span> <span class="o">=</span> <span class="p">{</span>
                <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Layer name&quot;</span><span class="p">,</span>
                <span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">gdf</span><span class="p">[</span><span class="n">gdf</span><span class="o">.</span><span class="n">cl</span> <span class="o">==</span> <span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">to_json</span><span class="p">()),</span>
                <span class="s2">&quot;sourcetype&quot;</span><span class="p">:</span> <span class="s2">&quot;geojson&quot;</span><span class="p">,</span>
                <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;fill&quot;</span><span class="p">,</span>
                <span class="s2">&quot;opacity&quot;</span><span class="p">:</span> <span class="mf">0.8</span><span class="p">,</span>
                <span class="s2">&quot;color&quot;</span><span class="p">:</span> <span class="n">lyr</span><span class="p">,</span>
            <span class="p">}</span>
            <span class="n">layers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>

        <span class="n">tmp</span><span class="p">[</span><span class="s2">&quot;layout&quot;</span><span class="p">][</span><span class="s2">&quot;mapbox&quot;</span><span class="p">][</span><span class="s2">&quot;layers&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">layers</span>
        <span class="n">tmp</span><span class="p">[</span><span class="s2">&quot;layout&quot;</span><span class="p">][</span><span class="s2">&quot;mapbox&quot;</span><span class="p">][</span><span class="s2">&quot;center&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;lat&quot;</span><span class="p">:</span> <span class="n">gdf</span><span class="o">.</span><span class="n">unary_union</span><span class="o">.</span><span class="n">centroid</span><span class="o">.</span><span class="n">y</span><span class="p">,</span>
            <span class="s2">&quot;lon&quot;</span><span class="p">:</span> <span class="n">gdf</span><span class="o">.</span><span class="n">unary_union</span><span class="o">.</span><span class="n">centroid</span><span class="o">.</span><span class="n">x</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="n">tmp</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s2">&quot;text&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">gdf</span><span class="p">[</span><span class="s2">&quot;geoid&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">tmp</span>

    <span class="nd">@app</span><span class="o">.</span><span class="n">callback</span><span class="p">(</span><span class="n">dash</span><span class="o">.</span><span class="n">dependencies</span><span class="o">.</span><span class="n">Output</span><span class="p">(</span><span class="s2">&quot;loading-output-1&quot;</span><span class="p">,</span> <span class="s2">&quot;children&quot;</span><span class="p">))</span>
    <span class="k">def</span> <span class="nf">input_triggers_spinner</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span>

    <span class="n">webbrowser</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s2">&quot;http://127.0.0.1:8050&quot;</span><span class="p">)</span>
    <span class="n">app</span><span class="o">.</span><span class="n">run_server</span><span class="p">()</span></div>


<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">explore</span><span class="p">()</span>
</pre></div>

    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
        <br/>
        
      
    </p>
    <p>
        &copy; Copyright 2020, geosnap developers.<br/>
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.4.4.<br/>
    </p>
  </div>
</footer>
  </body>
</html>